<?php
namespace jy_cxjxiche;
defined('BY_JYA') or exit('error');
/*
	任务
*/
class task extends \plugin{
	/*
		订单状态UP
	*/
	public function orderup($ismanage=false){
		$setting=$this->plugin_setting('setting');
		$params=array('uniacid'=>$_SESSION['uniacid']);
		$pindex = max(1, 0);
		$psize = 10;
		$total='';
		if(!$ismanage){
			$params['mid']=$_SESSION['uid'];
		}
		//关闭订单
		$params['status']=0;
		$setting['orderclosetime']=intval($setting['orderclosetime'])?:60;
		$orderclosetime=TIMESTAMP-intval($setting['orderclosetime'])*60;
		$params['createtime <']=$orderclosetime;
		$order = pdo_getslice('jy_cxjxiche_order',$params,array($pindex,$psize),$total,array('id'));
		if($order){
			foreach($order as $a){
				if($a['id']){
					$this->model('order')->order_cancel($a['id'],true);
				}			
			}
		}
		//司机下线
		$params=array('uniacid'=>$_SESSION['uniacid'],'busy'=>1);
		$setting['off_time']=intval($setting['off_time'])?:10;
		$off_time=TIMESTAMP-intval($setting['off_time'])*60;
		$params['uplat_time <']=$off_time;
		//pdo_update('jy_cxjxiche_worker',array('busy'=>0),$params);
	}
}